import pygame

class Creditos:
    '''Clase simple para mostrar los creditos'''
    def __init__(self,screen):
        self.x = 20
        self.y = 100
        self.font_name = pygame.font.get_default_font()
        self.font_size = 14
        self.font_color = (255,255,255,0)
        self.textList = ""
        self.screen = screen

    def printText(self):
        for line in self.textList:
            if line[:2] == "==":
                font = pygame.font.Font(self.font_name,self.font_size + 15)
            elif line[:1] == "=": 
                font = pygame.font.Font(self.font_name,self.font_size + 10)
            else:
                font = pygame.font.Font(self.font_name,self.font_size)
            
            text = font.render(line[2:], 1 , self.font_color)
            self.screen.blit(text, (self.x,self.y)) 
            self.y += text.get_height()

    def readFile(self):
        try:
            file = open(self.fileName, 'r')
            fileList = file.readlines()
            file.close()
            self.textList = fileList
    
        except IOError, (errno, strerror):
            print "I/O error(%s): %s %s" % (errno, strerror, self.fileName)
        except:
            print "Unexpected error:", sys.exc_info()
